package com.iwe3.protal.config;

import com.google.common.hash.BloomFilter;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

/**
 * CommandLineRunner 接口：SpringBoot应用执行 初始化
 */
@Component
public class InitKey2BloomFilter implements CommandLineRunner {

    private final BloomFilter bloomFilter;

    public InitKey2BloomFilter(BloomFilter bloomFilter) {
        this.bloomFilter = bloomFilter;
    }


    @Override
    public void run(String... args) throws Exception {
        String[] keys = {"booktop10","bookTypes"};
        for (String key : keys) {
            bloomFilter.put(key); //将合法的KEY，加入：布隆过滤器
        }
    }
}
